package com.xxx.obj;

/**
 * @version v1.0
 * @Description:
 * @Author zhanzhongxin
 * @Date 2021/7/16 15:19
 * @Copyright 博为峰
 */
public class Test {
    public static void main(String[] args) {
        Student s1 = new Student("张三", 20);
        Student s2 = new Student("张三", 20);
//        System.out.println(s1 == s2);//== 比较的是地址值

//        System.out.println(s1.equals(s2));//重写

        String str1 = "abc";
        String str2 = "abc";
//        System.out.println(str1 == str2);
//        System.out.println(str1.equals(str2));
//
//        System.out.println(s1.hashCode());
//        System.out.println(s2.hashCode());

        /*
           当判断对象中封装的数据是否相等时
           1.对象的hashCode()方法的返回值相同
           2.对象的equals(Object obj)方法的比较的数据相同

         */

        System.out.println(s1);
        System.out.println(s2);
        System.out.println(str1);
        System.out.println(str2);
    }
}
